home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectShow / Builder / Selpin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  11.5 KB  |  288 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSelectPin 
  3.    Caption         =   "Connect to Pin"
  4.    ClientHeight    =   3210
  5.    ClientLeft      =   4890
  6.    ClientTop       =   4920
  7.    ClientWidth     =   6270
  8.    LinkTopic       =   "Form2"
  9.    LockControls    =   -1  'True
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   3210
  12.    ScaleWidth      =   6270
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.ListBox listPins 
  15.       Height          =   1425
  16.       ItemData        =   "Selpin.frx":0000
  17.       Left            =   3360
  18.       List            =   "Selpin.frx":0002
  19.       TabIndex        =   3
  20.       Top             =   360
  21.       Width           =   2655
  22.    End
  23.    Begin VB.ListBox listFilters 
  24.       Height          =   1425
  25.       ItemData        =   "Selpin.frx":0004
  26.       Left            =   240
  27.       List            =   "Selpin.frx":0006
  28.       TabIndex        =   2
  29.       Top             =   360
  30.       Width           =   2655
  31.    End
  32.    Begin VB.CommandButton Cancel 
  33.       Cancel          =   -1  'True
  34.       Caption         =   "Cancel"
  35.       Height          =   375
  36.       Left            =   3360
  37.       TabIndex        =   1
  38.       Top             =   2640
  39.       Width           =   975
  40.    End
  41.    Begin VB.CommandButton OK 
  42.       Caption         =   "OK"
  43.       Default         =   -1  'True
  44.       Height          =   375
  45.       Left            =   1920
  46.       TabIndex        =   0
  47.       Top             =   2640
  48.       Width           =   975
  49.    End
  50.    Begin VB.Label Label2 
  51.       Caption         =   "Pins"
  52.       Height          =   252
  53.       Left            =   3240
  54.       TabIndex        =   7
  55.       Top             =   120
  56.       Width           =   492
  57.    End
  58.    Begin VB.Label VendorInfoLabel 
  59.       Caption         =   "Vendor Info:"
  60.       Height          =   252
  61.       Left            =   120
  62.       TabIndex        =   6
  63.       Top             =   2160
  64.       Width           =   972
  65.    End
  66.    Begin VB.Label VendorInfo 
  67.       Height          =   252
  68.       Left            =   1320
  69.       TabIndex        =   5
  70.       Top             =   2160
  71.       Visible         =   0   'False
  72.       Width           =   2772
  73.    End
  74.    Begin VB.Label Label1 
  75.       Caption         =   "Filters"
  76.       Height          =   255
  77.       Left            =   120
  78.       TabIndex        =   4
  79.       Top             =   120
  80.       Width           =   495
  81.    End
  82. Attribute VB_Name = "frmSelectPin"
  83. Attribute VB_GlobalNameSpace = False
  84. Attribute VB_Creatable = False
  85. Attribute VB_PredeclaredId = True
  86. Attribute VB_Exposed = False
  87. '*******************************************************************************
  88. '*       This is a part of the Microsoft DXSDK Code Samples.
  89. '*       Copyright (C) 1999-2001 Microsoft Corporation.
  90. '*       All rights reserved.
  91. '*       This source code is only intended as a supplement to
  92. '*       Microsoft Development Tools and/or SDK documentation.
  93. '*       See these sources for detailed information regarding the
  94. '*       Microsoft samples programs.
  95. '*******************************************************************************
  96. Option Explicit
  97. Option Base 0
  98. Option Compare Text
  99. Public g_objFI As IFilterInfo
  100. Public g_objPI As IPinInfo
  101. Public g_objMC As IMediaControl
  102. Public OtherDir As Long
  103. Public bOK As Boolean
  104. ' **************************************************************************************************************************************
  105. ' * PRIVATE INTERFACE- INTRINSIC VBFORM EVENT HANDLERS
  106.             ' ******************************************************************************************************************************
  107.             ' * procedure name: Form_Load
  108.             ' * procedure description:   fills the filters listbox with all filters in the current filter graph
  109.             ' *
  110.             ' ******************************************************************************************************************************
  111.             Private Sub Form_Load()
  112.             On Local Error GoTo ErrLine
  113.             Call RefreshFilters
  114.             Exit Sub
  115.             
  116. ErrLine:
  117.             Err.Clear
  118.             Exit Sub
  119.             End Sub
  120.             
  121. ' **************************************************************************************************************************************
  122. ' * PRIVATE INTERFACE- CONTROL EVENT HANDLERS
  123.             ' ******************************************************************************************************************************
  124.             ' * procedure name: Cancel_Click
  125.             ' * procedure description:    cancel command button click event-  no pin connection is made
  126.             ' *
  127.             ' ******************************************************************************************************************************
  128.             Private Sub Cancel_Click()
  129.             On Local Error GoTo ErrLine
  130.             bOK = False: Call Hide
  131.             Exit Sub
  132.             
  133. ErrLine:
  134.             Err.Clear
  135.             Exit Sub
  136.             End Sub
  137.             
  138.             
  139.             
  140.             ' ******************************************************************************************************************************
  141.             ' * procedure name: listFilters_Click
  142.             ' * procedure description:    when the user clicks on a specific filter in the filter graph, this creates the
  143.             ' *                                         list of pins for that filter in the pin listbox
  144.             ' ******************************************************************************************************************************
  145.             Private Sub listFilters_Click()
  146.             Dim pin As IPinInfo
  147.             Dim pfilter As IFilterInfo
  148.             Dim pinOther As IPinInfo
  149.             On Local Error GoTo ErrLine
  150.             
  151.             'enumerate through each filter in the filter collection
  152.             For Each pfilter In g_objMC.FilterCollection
  153.                 If LCase(pfilter.Name) = LCase(listFilters.Text) Then
  154.                     ' display the information and pins for the selected filter
  155.                     Set g_objFI = pfilter  ' global FilterInfo object
  156.                     VendorInfo.Caption = pfilter.VendorInfo
  157.                     listPins.Clear
  158.                     'enumerate through each pin in the filter
  159.                     For Each pin In pfilter.Pins
  160.                         Set pinOther = pin.ConnectedTo
  161.                         If Err.Number <> 0 Then
  162.                             If pin.Direction <> OtherDir Then
  163.                                 'append the pin's name to the listbox
  164.                                 listPins.AddItem pin.Name
  165.                             End If
  166.                         End If
  167.                     Next
  168.                 End If
  169.             Next
  170.             
  171.             'reset the selected index
  172.             If listPins.ListCount > 0 Then
  173.                listPins.ListIndex = 0
  174.             End If
  175.             'clean-up & dereference local data
  176.             If Not pin Is Nothing Then Set pin = Nothing
  177.             If Not pfilter Is Nothing Then Set pfilter = Nothing
  178.             If Not pinOther Is Nothing Then Set pinOther = Nothing
  179.             Exit Sub
  180.             
  181. ErrLine:
  182.             Err.Clear
  183.             Resume Next
  184.             End Sub
  185.             
  186.             
  187.             
  188.             
  189.             
  190.             ' ******************************************************************************************************************************
  191.             ' * procedure name: RefreshFilters
  192.             ' * procedure description:    fills the filters listbox with all filters in the current filter graph
  193.             ' *
  194.             ' ******************************************************************************************************************************
  195.             Public Sub RefreshFilters()
  196.             Dim pin As IPinInfo
  197.             Dim filter As IFilterInfo
  198.             Dim pinOther As IPinInfo
  199.             On Local Error GoTo ErrLine
  200.             
  201.             'clear the filter listbox
  202.             listFilters.Clear
  203.                
  204.             For Each filter In g_objMC.FilterCollection
  205.                 For Each pin In filter.Pins
  206.                     On Error Resume Next
  207.                     Set pinOther = pin.ConnectedTo
  208.                     If Err.Number <> 0 Then
  209.                         If pin.Direction <> OtherDir Then
  210.                             listFilters.AddItem filter.Name
  211.                             Exit For
  212.                         End If
  213.                     End If
  214.                 Next
  215.             Next
  216.             
  217.             'reset the list index
  218.             If listFilters.ListCount > 0 Then
  219.                listFilters.ListIndex = 0
  220.             End If
  221.             
  222.             'clean-up & dereference local data
  223.             If Not pin Is Nothing Then Set pin = Nothing
  224.             If Not filter Is Nothing Then Set filter = Nothing
  225.             If Not pinOther Is Nothing Then Set pinOther = Nothing
  226.             Exit Sub
  227.             
  228. ErrLine:
  229.             Err.Clear
  230.             Resume Next
  231.             End Sub
  232.             
  233.             
  234.             ' ******************************************************************************************************************************
  235.             ' * procedure name: OK_Click
  236.             ' * procedure description:    connect the selected pins, if possible. if no connection is possible, the pin
  237.             ' *                                         selection box closes and the program continues normally.
  238.             ' ******************************************************************************************************************************
  239.             Private Sub OK_Click()
  240.             Dim objPinInfo As IPinInfo
  241.             On Local Error GoTo ErrLine
  242.             
  243.             For Each objPinInfo In g_objFI.Pins
  244.                 If objPinInfo.Name = listPins.Text Then
  245.                     Set g_objPI = objPinInfo
  246.                     bOK = True
  247.                     Exit For
  248.                 End If
  249.             Next
  250.             
  251.             'unload form
  252.             Unload Me
  253.             
  254.             'clean-up & dereference local data
  255.             If Not objPinInfo Is Nothing Then Set objPinInfo = Nothing
  256.             Exit Sub
  257.             
  258. ErrLine:
  259.             Err.Clear
  260.             Exit Sub
  261.             End Sub
  262.             
  263.             
  264.             ' ******************************************************************************************************************************
  265.             ' * procedure name: listPins_Click
  266.             ' * procedure description:    When a new pin is selected, store it in the module-level pin object
  267.             ' *
  268.             ' ******************************************************************************************************************************
  269.             Private Sub listPins_Click()
  270.             Dim objPinInfo As IPinInfo
  271.             On Local Error GoTo ErrLine
  272.              
  273.             'enumerate the pins
  274.             For Each objPinInfo In g_objFI.Pins
  275.               If LCase(objPinInfo.Name) = LCase(listPins.Text) Then
  276.                  Set g_objPI = objPinInfo 'reset the selected module-level pin
  277.               End If
  278.             Next
  279.             
  280.             'clean-up & dereference local data
  281.             If Not objPinInfo Is Nothing Then Set objPinInfo = Nothing
  282.             Exit Sub
  283.             
  284. ErrLine:
  285.             Err.Clear
  286.             Exit Sub
  287.             End Sub
  288.